<template>
  <div class="page-header-index-wide">
    <!--  login 第一区域 新增 统计 小卡片-->
    <a-row :gutter="24">
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
            <div style='display: flex; flex-direction:row-revers; background-color:#FFFFFF' >
              <div>
                <img src='../../assets/user_p.png' alt="" style='width: 74px;height: 74px;margin: 28px 0px 28px 20px; '>
              </div>
              <div style='flex: 1'>
                <chart-card :loading="loading" title="新增客户" :total="20+' 人'">
                  <a-tooltip title="指标说明" slot="action">
                    <a-icon type="info-circle-o" />
                  </a-tooltip>
                  <div>
                    <mini-area />
                  </div>
                  <template slot="footer">
                    <trend flag="down" style="margin-right: 16px;">
                      <span slot="term">同周比</span>
                      <span style='color: #56CC66'>60%</span>
                    </trend>
                  </template>
                </chart-card>
              </div>
            </div>
      </a-col>

      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <div style='display: flex; flex-direction:row-revers; background-color:#FFFFFF' >
          <div>
            <img src='../../assets/equipment1x.png' alt="" style='width: 74px;height: 74px;margin: 28px 0px 28px 20px; '>
          </div>
          <div style='flex: 1'>
            <chart-card :loading="loading" title="设备卖出" :total="20+' 台'">
              <a-tooltip title="指标说明" slot="action">
                <a-icon type="info-circle-o" />
              </a-tooltip>
              <div>
                <mini-area />
              </div>
              <template slot="footer">
                <trend flag="down" style="margin-right: 16px;">
                  <span slot="term">同周比</span>
                  <span style='color: #56CC66'>60%</span>
                </trend>
              </template>
            </chart-card>
          </div>
        </div>
      </a-col>

      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="支付笔数" :total="6560 | NumberFormat">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <mini-bar :height="40" />
          </div>
          <template slot="footer">
            <trend flag="down" style="margin-right: 16px;">
              <span slot="term">同周比</span>
              <span style='color: #56CC66'>60%</span>
            </trend>
          </template>
        </chart-card>
      </a-col>
      <a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
        <chart-card :loading="loading" title="运营活动效果" total="78%">
          <a-tooltip title="指标说明" slot="action">
            <a-icon type="info-circle-o" />
          </a-tooltip>
          <div>
            <mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" :height="8" />
          </div>
          <template slot="footer">
            <trend flag="down" style="margin-right: 16px;">
              <span slot="term">同周比</span>
              12%
            </trend>
          </template>
        </chart-card>
      </a-col>
    </a-row>

    <!--  login 第二区域 试戴数据统计-->
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="试戴次数统计" :style="{ marginTop: '24px' }">
          <a-col :span="24" :style="{ marginBottom: '24px' }">
            <a-row>
              <a-col >
                <radio-archives />
              </a-col>
            </a-row>
          </a-col>
        </a-card>
      </a-col>
    </a-row>

    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="试戴种类占比" :style="{ marginTop: '24px' }">
          <a-col :sm="24" :md="16" :xl="16" :style="{ marginBottom: '24px' }">
            <a-row>
              <a-col :xl="14" :lg="12" :md="12" :sm="24" :xs="24">
                <donut/>
                <donut-half/>
              </a-col>
            </a-row>
          </a-col>
        </a-card>
      </a-col>
    </a-row>

    <!--  login 第三区域 客户统计-->
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="客户统计" :style="{ marginTop: '24px' }">
          <position-list></position-list>
        </a-card>
      </a-col>
    </a-row>

    <!--  login 第四区域 地域分布-->
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="地域分布" :style="{ marginTop: '24px' }">

           </a-card>
      </a-col>
    </a-row>
    <!--  login 第五区域 设备试戴次数统计-->
    <a-row>
      <a-col :span="24">
        <a-card :loading="loading" :bordered="false" title="设备试戴次数统计" :style="{ marginTop: '24px' }">
          <equipment-list/>
        </a-card>
      </a-col>
    </a-row>
  </div>
</template>

<script>
  import ChartCard from '@/components/ChartCard'
  import ACol from "ant-design-vue/es/grid/Col"
  import ATooltip from "ant-design-vue/es/tooltip/Tooltip"
  import MiniArea from '@/components/chart/MiniArea'
  import MiniBar from '@/components/chart/MiniBar'
  import MiniProgress from '@/components/chart/MiniProgress'
  import RankList from '@/components/chart/RankList'
  import Bar from '@/components/chart/Bar'
  import LineChartMultid from '@/components/chart/LineChartMultid'
  import HeadInfo from '@/components/tools/HeadInfo.vue'
  import Pie from '@/components/chart/Pie'  //饼状图
  import DonutHalf from '@/components/chart/DonutHalf'  //半环状图
  import DonutWen from '@/components/chart/DonutWen'  //
  import Trend from '@/components/Trend'
  import RadioArchives from './RadioArchives'
  import { getLoginfo,getVisitInfo } from '@/api/api'
  import PositionList from '@views/dashboardss/PositionList'
  import EquipmentList from '@views/dashboardss/EquipmentList'

  const rankList = []
  for (let i = 0; i < 7; i++) {
    rankList.push({
      name: '白鹭岛 ' + (i+1) + ' 号店',
      total: 1234.56 - i * 100
    })
  }
  const DonutData=[]
  const barData = [
    {x:`美妆`,
      y:22},
    {x:`眼镜`,
      y:36},
    {x:`测肤`,
      y:17},
    {x:`美发`,
      y:9},
    {x:`珠宝`,
      y:39},
  ]

  const pieData = [
    { item: '示例一', count: 40 },
    { item: '示例二', count: 21 },
    { item: '示例三', count: 17 },
    { item: '示例四', count: 13 },
    { item: '示例五', count: 9 }
  ]
  // for (let i = 0; i < 12; i += 1) {
  //   barData.push({
  //     x: `${i + 1}月`,
  //     y: Math.floor(Math.random() * 1000) + 200
  //   })
  // }
  export default {
    name: "IndexChart",
    components: {
      PositionList,
      ATooltip,
      ACol,
      ChartCard,
      MiniArea,
      MiniBar,
      MiniProgress,
      RankList,
      Bar,
      RadioArchives,
      DonutHalf,
      DonutWen,
      Trend,
      LineChartMultid,
      HeadInfo,
      Pie,
      EquipmentList,
    },
    data() {
      return {
        loading: true,
        center: null,
        rankList,
        barData,
        pieData,
        loginfo:{},
        visitFields:['ip','visit'],
        visitInfo:[],
        indicator: <a-icon type="loading" style="font-size: 24px" spin />,
        //图表数据//
        lineData:[
          {year: '10/20',
            value: 30
          }, {
            year: '10/21',
            value: 40
          }, {
            year: '10/22',
            value: 30.5
          }, {
            year: '10/23',
            value: 50
          }, {
            year: '10/24',
            value: 40.9
          }, {
            year: '10/25',
            value: 60
          }, {
            year: '10/26',
            value: 70
          }, {
            year: '10/27',
            value: 90
          }, {
            year: '10/28',
            value: 63
          }]
        //图表
    };

    },
    created() {
      setTimeout(() => {
        this.loading = !this.loading
      }, 1000)
      this.initLogInfo();
    },
    methods: {
      initLogInfo () {
        getLoginfo(null).then((res)=>{
          if(res.success){
            Object.keys(res.result).forEach(key=>{
              res.result[key] =res.result[key]+""
            })
            this.loginfo = res.result;
          }
        })
        getVisitInfo().then(res=>{
          if(res.success){
             this.visitInfo = res.result;
           }
         })
      },
    },
    mounted: function() {
      const vm = this
      vm.$nextTick(()=> {})
    }
  }
</script>

<style lang="less" scoped>
  .circle-cust{
    position: relative;
    top: 28px;
    left: -100%;
  }
  .extra-wrapper {
    line-height: 55px;
    padding-right: 24px;

    .extra-item {
      display: inline-block;
      margin-right: 24px;

      a {
        margin-left: 24px;
      }
    }
  }

  .echart-wrapper {
    width: 300px;
    height: 300px;
    margin: 10px auto;
  }

  .meta {
    position: relative;
    overflow: hidden;
    width: 100%;
    color: rgba(0, 0, 0, .45);
    font-size: 14px;
    line-height: 22px;
  }

  /* 首页访问量统计 */
  .head-info {
    position: relative;
    text-align: left;
    padding: 0 32px 0 0;
    min-width: 125px;

    &.center {
      text-align: center;
      padding: 0 32px;
    }

    span {
      color: rgba(0, 0, 0, .45);
      display: inline-block;
      font-size: .95rem;
      line-height: 42px;
      margin-bottom: 4px;
    }
    p {
      line-height: 42px;
      margin: 0;
      a {
        font-weight: 600;
        font-size: 1rem;
      }
    }
  }
</style>